/*
 * Copyright (C) 2011, EADS France
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */
package xowl.interpreter.backends.rete;

import java.util.IdentityHashMap;
import java.util.Map;
import xowl.interpreter.backends.rdf.RDFNode;
import xowl.interpreter.backends.rdf.XOWLVariableNode;

/**
 *
 * @author Laurent WOUTERS
 */
public class Token {
    private Token parent;
    private Map<XOWLVariableNode, RDFNode> bindings;
    
    public Token getParent() { return parent; }
    
    public Token(Token parent) {
        this.parent = parent;
        if (parent != null)
            this.bindings = new IdentityHashMap<XOWLVariableNode, RDFNode>(parent.bindings);
        else
            this.bindings = new IdentityHashMap<XOWLVariableNode, RDFNode>();
    }
    
    public void bind(XOWLVariableNode var, RDFNode value) { bindings.put(var, value); }
    
    public RDFNode getBinding(XOWLVariableNode var) { return bindings.get(var); }
    
    public Map<XOWLVariableNode, RDFNode> getBindings() { return bindings; }
}
